package o;

import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import o.fc.c;

public final class fur {
    private static final char[] ˊ = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
    private final String ʻ;
    @Nullable
    private final List<String> ʼ;
    @Nullable
    private final String ʽ;
    final String ˋ;
    final String ˎ;
    final int ˏ;
    private final String ॱ;
    private final String ॱॱ;
    private final List<String> ᐝ;

    public static final class a {
        final List<String> ʼ = new ArrayList();
        @Nullable
        List<String> ʽ;
        String ˊ = "";
        String ˋ = "";
        int ˎ = -1;
        @Nullable
        String ˏ;
        @Nullable
        String ॱ;
        @Nullable
        String ᐝ;

        public a() {
            this.ʼ.add("");
        }

        public a ˋ(String str) {
            if (str == null) {
                throw new NullPointerException("scheme == null");
            }
            if (str.equalsIgnoreCase("http")) {
                this.ˏ = "http";
            } else if (str.equalsIgnoreCase("https")) {
                this.ˏ = "https";
            } else {
                throw new IllegalArgumentException("unexpected scheme: " + str);
            }
            return this;
        }

        public a ॱ(String str) {
            if (str == null) {
                throw new NullPointerException("username == null");
            }
            this.ˊ = fur.ˊ(str, " \"':;<=>@[]^`{}|/\\?#", false, false, false, true);
            return this;
        }

        public a ˊ(String str) {
            if (str == null) {
                throw new NullPointerException("password == null");
            }
            this.ˋ = fur.ˊ(str, " \"':;<=>@[]^`{}|/\\?#", false, false, false, true);
            return this;
        }

        public a ˎ(String str) {
            if (str == null) {
                throw new NullPointerException("host == null");
            }
            String ˏ = ˏ(str, 0, str.length());
            if (ˏ == null) {
                throw new IllegalArgumentException("unexpected host: " + str);
            }
            this.ॱ = ˏ;
            return this;
        }

        public a ˏ(int i) {
            if (i <= 0 || i > 65535) {
                throw new IllegalArgumentException("unexpected port: " + i);
            }
            this.ˎ = i;
            return this;
        }

        int ˊ() {
            return this.ˎ != -1 ? this.ˎ : fur.ˎ(this.ˏ);
        }

        public a ˏ(@Nullable String str) {
            List ˋ;
            if (str != null) {
                ˋ = fur.ˋ(fur.ˊ(str, " \"'<>#", true, false, true, true));
            } else {
                ˋ = null;
            }
            this.ʽ = ˋ;
            return this;
        }

        public a ˊ(String str, @Nullable String str2) {
            if (str == null) {
                throw new NullPointerException("name == null");
            }
            Object ˊ;
            if (this.ʽ == null) {
                this.ʽ = new ArrayList();
            }
            this.ʽ.add(fur.ˊ(str, " !\"#$&'(),/:;<=>?@[]\\^`{|}~", false, false, true, true));
            List list = this.ʽ;
            if (str2 != null) {
                ˊ = fur.ˊ(str2, " !\"#$&'(),/:;<=>?@[]\\^`{|}~", false, false, true, true);
            } else {
                ˊ = null;
            }
            list.add(ˊ);
            return this;
        }

        public a ˎ(String str, @Nullable String str2) {
            ʻ(str);
            ˊ(str, str2);
            return this;
        }

        public a ʻ(String str) {
            if (str == null) {
                throw new NullPointerException("name == null");
            }
            if (this.ʽ != null) {
                ʽ(fur.ˊ(str, " !\"#$&'(),/:;<=>?@[]\\^`{|}~", false, false, true, true));
            }
            return this;
        }

        private void ʽ(String str) {
            for (int size = this.ʽ.size() - 2; size >= 0; size -= 2) {
                if (str.equals(this.ʽ.get(size))) {
                    this.ʽ.remove(size + 1);
                    this.ʽ.remove(size);
                    if (this.ʽ.isEmpty()) {
                        this.ʽ = null;
                        return;
                    }
                }
            }
        }

        a ˋ() {
            int size = this.ʼ.size();
            for (int i = 0; i < size; i++) {
                this.ʼ.set(i, fur.ˊ((String) this.ʼ.get(i), "[]", true, true, false, true));
            }
            if (this.ʽ != null) {
                int size2 = this.ʽ.size();
                for (int i2 = 0; i2 < size2; i2++) {
                    String str = (String) this.ʽ.get(i2);
                    if (str != null) {
                        this.ʽ.set(i2, fur.ˊ(str, "\\^`{|}", true, true, true, true));
                    }
                }
            }
            if (this.ᐝ != null) {
                this.ᐝ = fur.ˊ(this.ᐝ, " \"#<>\\^`{|}", true, true, false, false);
            }
            return this;
        }

        public fur ॱ() {
            if (this.ˏ == null) {
                throw new IllegalStateException("scheme == null");
            } else if (this.ॱ != null) {
                return new fur(this);
            } else {
                throw new IllegalStateException("host == null");
            }
        }

        public String toString() {
            StringBuilder stringBuilder = new StringBuilder();
            if (this.ˏ != null) {
                stringBuilder.append(this.ˏ);
                stringBuilder.append("://");
            } else {
                stringBuilder.append("//");
            }
            if (!(this.ˊ.isEmpty() && this.ˋ.isEmpty())) {
                stringBuilder.append(this.ˊ);
                if (!this.ˋ.isEmpty()) {
                    stringBuilder.append(':');
                    stringBuilder.append(this.ˋ);
                }
                stringBuilder.append('@');
            }
            if (this.ॱ != null) {
                if (this.ॱ.indexOf(58) != -1) {
                    stringBuilder.append('[');
                    stringBuilder.append(this.ॱ);
                    stringBuilder.append(']');
                } else {
                    stringBuilder.append(this.ॱ);
                }
            }
            if (!(this.ˎ == -1 && this.ˏ == null)) {
                int ˊ = ˊ();
                if (this.ˏ == null || ˊ != fur.ˎ(this.ˏ)) {
                    stringBuilder.append(':');
                    stringBuilder.append(ˊ);
                }
            }
            fur.ˎ(stringBuilder, this.ʼ);
            if (this.ʽ != null) {
                stringBuilder.append('?');
                fur.ˊ(stringBuilder, this.ʽ);
            }
            if (this.ᐝ != null) {
                stringBuilder.append('#');
                stringBuilder.append(this.ᐝ);
            }
            return stringBuilder.toString();
        }

        a ˊ(@Nullable fur o_fur, String str) {
            int ॱ;
            int ˏ = fvg.ˏ(str, 0, str.length());
            int ˋ = fvg.ˋ(str, ˏ, str.length());
            int ˋ2 = ˋ(str, ˏ, ˋ);
            if (ˋ2 != -1) {
                if (str.regionMatches(true, ˏ, "https:", 0, 6)) {
                    this.ˏ = "https";
                    ˏ += "https:".length();
                } else {
                    if (str.regionMatches(true, ˏ, "http:", 0, 5)) {
                        this.ˏ = "http";
                        ˏ += "http:".length();
                    } else {
                        throw new IllegalArgumentException("Expected URL scheme 'http' or 'https' but was '" + str.substring(0, ˋ2) + "'");
                    }
                }
            } else if (o_fur != null) {
                this.ˏ = o_fur.ˎ;
            } else {
                throw new IllegalArgumentException("Expected URL scheme 'http' or 'https' but no colon was found");
            }
            int ˊ = ˊ(str, ˏ, ˋ);
            if (ˊ >= 2 || o_fur == null || !o_fur.ˎ.equals(this.ˏ)) {
                Object obj = null;
                Object obj2 = null;
                int i = ˏ + ˊ;
                while (true) {
                    char charAt;
                    Object obj3;
                    Object obj4;
                    int ॱ2 = fvg.ॱ(str, i, ˋ, "@/\\?#");
                    if (ॱ2 != ˋ) {
                        charAt = str.charAt(ॱ2);
                    } else {
                        charAt = '￿';
                    }
                    switch (charAt) {
                        case '￿':
                        case '#':
                        case '/':
                        case c.ㆍॱ /*63*/:
                        case '\\':
                            ॱ = ॱ(str, i, ॱ2);
                            if (ॱ + 1 < ॱ2) {
                                this.ॱ = ˏ(str, i, ॱ);
                                this.ˎ = ʼ(str, ॱ + 1, ॱ2);
                                if (this.ˎ == -1) {
                                    throw new IllegalArgumentException("Invalid URL port: \"" + str.substring(ॱ + 1, ॱ2) + '\"');
                                }
                            }
                            this.ॱ = ˏ(str, i, ॱ);
                            this.ˎ = fur.ˎ(this.ˏ);
                            if (this.ॱ != null) {
                                ˏ = ॱ2;
                                break;
                            }
                            throw new IllegalArgumentException("Invalid URL host: \"" + str.substring(i, ॱ) + '\"');
                        case '@':
                            if (obj == null) {
                                ˏ = fvg.ˊ(str, i, ॱ2, ':');
                                String ॱ3 = fur.ॱ(str, i, ˏ, " \"':;<=>@[]^`{}|/\\?#", true, false, false, true, null);
                                if (obj2 != null) {
                                    ॱ3 = this.ˊ + "%40" + ॱ3;
                                }
                                this.ˊ = ॱ3;
                                if (ˏ != ॱ2) {
                                    obj = 1;
                                    this.ˋ = fur.ॱ(str, ˏ + 1, ॱ2, " \"':;<=>@[]^`{}|/\\?#", true, false, false, true, null);
                                }
                                obj2 = 1;
                            } else {
                                this.ˋ += "%40" + fur.ॱ(str, i, ॱ2, " \"':;<=>@[]^`{}|/\\?#", true, false, false, true, null);
                            }
                            ˏ = ॱ2 + 1;
                            obj3 = obj;
                            obj4 = obj2;
                            continue;
                        default:
                            obj3 = obj;
                            ˏ = i;
                            obj4 = obj2;
                            continue;
                    }
                    obj = obj3;
                    obj2 = obj4;
                    i = ˏ;
                }
            } else {
                this.ˊ = o_fur.ˊ();
                this.ˋ = o_fur.ॱ();
                this.ॱ = o_fur.ˋ;
                this.ˎ = o_fur.ˏ;
                this.ʼ.clear();
                this.ʼ.addAll(o_fur.ᐝ());
                if (ˏ == ˋ || str.charAt(ˏ) == '#') {
                    ˏ(o_fur.ʼ());
                }
            }
            ॱ = fvg.ॱ(str, ˏ, ˋ, "?#");
            ˎ(str, ˏ, ॱ);
            if (ॱ >= ˋ || str.charAt(ॱ) != '?') {
                ˏ = ॱ;
            } else {
                ˏ = fvg.ˊ(str, ॱ, ˋ, '#');
                this.ʽ = fur.ˋ(fur.ॱ(str, ॱ + 1, ˏ, " \"'<>#", true, false, true, true, null));
            }
            if (ˏ < ˋ && str.charAt(ˏ) == '#') {
                this.ᐝ = fur.ॱ(str, ˏ + 1, ˋ, "", true, false, false, false, null);
            }
            return this;
        }

        private void ˎ(String str, int i, int i2) {
            if (i != i2) {
                char charAt = str.charAt(i);
                if (charAt == '/' || charAt == '\\') {
                    this.ʼ.clear();
                    this.ʼ.add("");
                    i++;
                } else {
                    this.ʼ.set(this.ʼ.size() - 1, "");
                }
                int i3 = i;
                while (i3 < i2) {
                    int ॱ = fvg.ॱ(str, i3, i2, "/\\");
                    boolean z = ॱ < i2;
                    ˋ(str, i3, ॱ, z, true);
                    if (z) {
                        ॱ++;
                    }
                    i3 = ॱ;
                }
            }
        }

        private void ˋ(String str, int i, int i2, boolean z, boolean z2) {
            String ॱ = fur.ॱ(str, i, i2, " \"<>^`{}|/\\?#", z2, false, false, true, null);
            if (!ॱॱ(ॱ)) {
                if (ʼ(ॱ)) {
                    ˏ();
                    return;
                }
                if (((String) this.ʼ.get(this.ʼ.size() - 1)).isEmpty()) {
                    this.ʼ.set(this.ʼ.size() - 1, ॱ);
                } else {
                    this.ʼ.add(ॱ);
                }
                if (z) {
                    this.ʼ.add("");
                }
            }
        }

        private boolean ॱॱ(String str) {
            return str.equals(".") || str.equalsIgnoreCase("%2e");
        }

        private boolean ʼ(String str) {
            return str.equals("..") || str.equalsIgnoreCase("%2e.") || str.equalsIgnoreCase(".%2e") || str.equalsIgnoreCase("%2e%2e");
        }

        private void ˏ() {
            if (!((String) this.ʼ.remove(this.ʼ.size() - 1)).isEmpty() || this.ʼ.isEmpty()) {
                this.ʼ.add("");
            } else {
                this.ʼ.set(this.ʼ.size() - 1, "");
            }
        }

        private static int ˋ(String str, int i, int i2) {
            if (i2 - i < 2) {
                return -1;
            }
            char charAt = str.charAt(i);
            if ((charAt < 'a' || charAt > 'z') && (charAt < 'A' || charAt > 'Z')) {
                return -1;
            }
            int i3 = i + 1;
            while (i3 < i2) {
                char charAt2 = str.charAt(i3);
                if ((charAt2 >= 'a' && charAt2 <= 'z') || ((charAt2 >= 'A' && charAt2 <= 'Z') || ((charAt2 >= '0' && charAt2 <= '9') || charAt2 == '+' || charAt2 == '-' || charAt2 == '.'))) {
                    i3++;
                } else if (charAt2 == ':') {
                    return i3;
                } else {
                    return -1;
                }
            }
            return -1;
        }

        private static int ˊ(String str, int i, int i2) {
            int i3 = 0;
            while (i < i2) {
                char charAt = str.charAt(i);
                if (charAt != '\\' && charAt != '/') {
                    break;
                }
                i3++;
                i++;
            }
            return i3;
        }

        /* JADX WARNING: inconsistent code. */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        private static int ॱ(java.lang.String r3, int r4, int r5) {
            /*
            r0 = r4;
        L_0x0001:
            if (r0 >= r5) goto L_0x001a;
        L_0x0003:
            r1 = r3.charAt(r0);
            switch(r1) {
                case 58: goto L_0x001b;
                case 91: goto L_0x000d;
                default: goto L_0x000a;
            };
        L_0x000a:
            r0 = r0 + 1;
            goto L_0x0001;
        L_0x000d:
            r0 = r0 + 1;
            if (r0 >= r5) goto L_0x000a;
        L_0x0011:
            r1 = r3.charAt(r0);
            r2 = 93;
            if (r1 != r2) goto L_0x000d;
        L_0x0019:
            goto L_0x000a;
        L_0x001a:
            r0 = r5;
        L_0x001b:
            return r0;
            */
            throw new UnsupportedOperationException("Method not decompiled: o.fur.a.ॱ(java.lang.String, int, int):int");
        }

        private static String ˏ(String str, int i, int i2) {
            return fvg.ˏ(fur.ˏ(str, i, i2, false));
        }

        private static int ʼ(String str, int i, int i2) {
            try {
                int parseInt = Integer.parseInt(fur.ॱ(str, i, i2, "", false, false, false, true, null));
                return (parseInt <= 0 || parseInt > 65535) ? -1 : parseInt;
            } catch (NumberFormatException e) {
                return -1;
            }
        }
    }

    fur(a aVar) {
        List ˋ;
        String str = null;
        this.ˎ = aVar.ˏ;
        this.ॱ = ˎ(aVar.ˊ, false);
        this.ॱॱ = ˎ(aVar.ˋ, false);
        this.ˋ = aVar.ॱ;
        this.ˏ = aVar.ˊ();
        this.ᐝ = ˋ(aVar.ʼ, false);
        if (aVar.ʽ != null) {
            ˋ = ˋ(aVar.ʽ, true);
        } else {
            ˋ = null;
        }
        this.ʼ = ˋ;
        if (aVar.ᐝ != null) {
            str = ˎ(aVar.ᐝ, false);
        }
        this.ʽ = str;
        this.ʻ = aVar.toString();
    }

    public URI ˏ() {
        String aVar = ˏॱ().ˋ().toString();
        try {
            return new URI(aVar);
        } catch (Throwable e) {
            try {
                return URI.create(aVar.replaceAll("[\\u0000-\\u001F\\u007F-\\u009F\\p{javaWhitespace}]", ""));
            } catch (Exception e2) {
                throw new RuntimeException(e);
            }
        }
    }

    public String ˋ() {
        return this.ˎ;
    }

    public boolean ˎ() {
        return this.ˎ.equals("https");
    }

    public String ˊ() {
        if (this.ॱ.isEmpty()) {
            return "";
        }
        int length = this.ˎ.length() + 3;
        return this.ʻ.substring(length, fvg.ॱ(this.ʻ, length, this.ʻ.length(), ":@"));
    }

    public String ॱ() {
        if (this.ॱॱ.isEmpty()) {
            return "";
        }
        return this.ʻ.substring(this.ʻ.indexOf(58, this.ˎ.length() + 3) + 1, this.ʻ.indexOf(64));
    }

    public String ʻ() {
        return this.ˋ;
    }

    public int ॱॱ() {
        return this.ˏ;
    }

    public static int ˎ(String str) {
        if (str.equals("http")) {
            return 80;
        }
        if (str.equals("https")) {
            return 443;
        }
        return -1;
    }

    public String ʽ() {
        int indexOf = this.ʻ.indexOf(47, this.ˎ.length() + 3);
        return this.ʻ.substring(indexOf, fvg.ॱ(this.ʻ, indexOf, this.ʻ.length(), "?#"));
    }

    static void ˎ(StringBuilder stringBuilder, List<String> list) {
        int size = list.size();
        for (int i = 0; i < size; i++) {
            stringBuilder.append('/');
            stringBuilder.append((String) list.get(i));
        }
    }

    public List<String> ᐝ() {
        int indexOf = this.ʻ.indexOf(47, this.ˎ.length() + 3);
        int ॱ = fvg.ॱ(this.ʻ, indexOf, this.ʻ.length(), "?#");
        List<String> arrayList = new ArrayList();
        while (indexOf < ॱ) {
            int i = indexOf + 1;
            indexOf = fvg.ˊ(this.ʻ, i, ॱ, '/');
            arrayList.add(this.ʻ.substring(i, indexOf));
        }
        return arrayList;
    }

    @Nullable
    public String ʼ() {
        if (this.ʼ == null) {
            return null;
        }
        int indexOf = this.ʻ.indexOf(63) + 1;
        return this.ʻ.substring(indexOf, fvg.ˊ(this.ʻ, indexOf, this.ʻ.length(), '#'));
    }

    static void ˊ(StringBuilder stringBuilder, List<String> list) {
        int size = list.size();
        for (int i = 0; i < size; i += 2) {
            String str = (String) list.get(i);
            String str2 = (String) list.get(i + 1);
            if (i > 0) {
                stringBuilder.append('&');
            }
            stringBuilder.append(str);
            if (str2 != null) {
                stringBuilder.append('=');
                stringBuilder.append(str2);
            }
        }
    }

    static List<String> ˋ(String str) {
        List<String> arrayList = new ArrayList();
        int i = 0;
        while (i <= str.length()) {
            int indexOf = str.indexOf(38, i);
            if (indexOf == -1) {
                indexOf = str.length();
            }
            int indexOf2 = str.indexOf(61, i);
            if (indexOf2 == -1 || indexOf2 > indexOf) {
                arrayList.add(str.substring(i, indexOf));
                arrayList.add(null);
            } else {
                arrayList.add(str.substring(i, indexOf2));
                arrayList.add(str.substring(indexOf2 + 1, indexOf));
            }
            i = indexOf + 1;
        }
        return arrayList;
    }

    @Nullable
    public String ˋॱ() {
        if (this.ʼ == null) {
            return null;
        }
        StringBuilder stringBuilder = new StringBuilder();
        ˊ(stringBuilder, this.ʼ);
        return stringBuilder.toString();
    }

    @Nullable
    public String ॱˊ() {
        if (this.ʽ == null) {
            return null;
        }
        return this.ʻ.substring(this.ʻ.indexOf(35) + 1);
    }

    public String ͺ() {
        return ˏ("/...").ॱ("").ˊ("").ॱ().toString();
    }

    @Nullable
    public fur ˊ(String str) {
        a ˏ = ˏ(str);
        return ˏ != null ? ˏ.ॱ() : null;
    }

    public a ˏॱ() {
        a aVar = new a();
        aVar.ˏ = this.ˎ;
        aVar.ˊ = ˊ();
        aVar.ˋ = ॱ();
        aVar.ॱ = this.ˋ;
        aVar.ˎ = this.ˏ != ˎ(this.ˎ) ? this.ˏ : -1;
        aVar.ʼ.clear();
        aVar.ʼ.addAll(ᐝ());
        aVar.ˏ(ʼ());
        aVar.ᐝ = ॱˊ();
        return aVar;
    }

    @Nullable
    public a ˏ(String str) {
        try {
            return new a().ˊ(this, str);
        } catch (IllegalArgumentException e) {
            return null;
        }
    }

    @Nullable
    public static fur ॱ(String str) {
        try {
            return ॱॱ(str);
        } catch (IllegalArgumentException e) {
            return null;
        }
    }

    public static fur ॱॱ(String str) {
        return new a().ˊ(null, str).ॱ();
    }

    public boolean equals(@Nullable Object obj) {
        return (obj instanceof fur) && ((fur) obj).ʻ.equals(this.ʻ);
    }

    public int hashCode() {
        return this.ʻ.hashCode();
    }

    public String toString() {
        return this.ʻ;
    }

    static String ˎ(String str, boolean z) {
        return ˏ(str, 0, str.length(), z);
    }

    private List<String> ˋ(List<String> list, boolean z) {
        int size = list.size();
        List arrayList = new ArrayList(size);
        for (int i = 0; i < size; i++) {
            String str = (String) list.get(i);
            arrayList.add(str != null ? ˎ(str, z) : null);
        }
        return Collections.unmodifiableList(arrayList);
    }

    static String ˏ(String str, int i, int i2, boolean z) {
        for (int i3 = i; i3 < i2; i3++) {
            char charAt = str.charAt(i3);
            if (charAt == '%' || (charAt == '+' && z)) {
                fxi o_fxi = new fxi();
                o_fxi.ˏ(str, i, i3);
                ˋ(o_fxi, str, i3, i2, z);
                return o_fxi.ॱᐝ();
            }
        }
        return str.substring(i, i2);
    }

    static void ˋ(fxi o_fxi, String str, int i, int i2, boolean z) {
        int i3 = i;
        while (i3 < i2) {
            int codePointAt = str.codePointAt(i3);
            if (codePointAt != 37 || i3 + 2 >= i2) {
                if (codePointAt == 43 && z) {
                    o_fxi.ˊ(32);
                }
                o_fxi.ˎ(codePointAt);
            } else {
                int ˊ = fvg.ˊ(str.charAt(i3 + 1));
                int ˊ2 = fvg.ˊ(str.charAt(i3 + 2));
                if (!(ˊ == -1 || ˊ2 == -1)) {
                    o_fxi.ˊ((ˊ << 4) + ˊ2);
                    i3 += 2;
                }
                o_fxi.ˎ(codePointAt);
            }
            i3 += Character.charCount(codePointAt);
        }
    }

    static boolean ˊ(String str, int i, int i2) {
        return i + 2 < i2 && str.charAt(i) == '%' && fvg.ˊ(str.charAt(i + 1)) != -1 && fvg.ˊ(str.charAt(i + 2)) != -1;
    }

    static String ॱ(String str, int i, int i2, String str2, boolean z, boolean z2, boolean z3, boolean z4, Charset charset) {
        int i3 = i;
        while (i3 < i2) {
            int codePointAt = str.codePointAt(i3);
            if (codePointAt < 32 || codePointAt == 127 || ((codePointAt >= DnsConfig.MAX_CACHE_ENTRIES && z4) || str2.indexOf(codePointAt) != -1 || ((codePointAt == 37 && (!z || (z2 && !ˊ(str, i3, i2)))) || (codePointAt == 43 && z3)))) {
                fxi o_fxi = new fxi();
                o_fxi.ˏ(str, i, i3);
                ˎ(o_fxi, str, i3, i2, str2, z, z2, z3, z4, charset);
                return o_fxi.ॱᐝ();
            }
            i3 += Character.charCount(codePointAt);
        }
        return str.substring(i, i2);
    }

    static void ˎ(fxi o_fxi, String str, int i, int i2, String str2, boolean z, boolean z2, boolean z3, boolean z4, Charset charset) {
        fxi o_fxi2 = null;
        while (i < i2) {
            int codePointAt = str.codePointAt(i);
            if (!(z && (codePointAt == 9 || codePointAt == 10 || codePointAt == 12 || codePointAt == 13))) {
                if (codePointAt == 43 && z3) {
                    o_fxi.ˎ(z ? "+" : "%2B");
                } else if (codePointAt < 32 || codePointAt == 127 || ((codePointAt >= DnsConfig.MAX_CACHE_ENTRIES && z4) || str2.indexOf(codePointAt) != -1 || (codePointAt == 37 && (!z || (z2 && !ˊ(str, i, i2)))))) {
                    if (o_fxi2 == null) {
                        o_fxi2 = new fxi();
                    }
                    if (charset == null || charset.equals(fvg.ˎ)) {
                        o_fxi2.ˎ(codePointAt);
                    } else {
                        o_fxi2.ˊ(str, i, Character.charCount(codePointAt) + i, charset);
                    }
                    while (!o_fxi2.ᐝ()) {
                        int ʻ = o_fxi2.ʻ() & 255;
                        o_fxi.ˊ(37);
                        o_fxi.ˊ(ˊ[(ʻ >> 4) & 15]);
                        o_fxi.ˊ(ˊ[ʻ & 15]);
                    }
                } else {
                    o_fxi.ˎ(codePointAt);
                }
            }
            i += Character.charCount(codePointAt);
        }
    }

    static String ˊ(String str, String str2, boolean z, boolean z2, boolean z3, boolean z4) {
        return ॱ(str, 0, str.length(), str2, z, z2, z3, z4, null);
    }
}
